<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item
        v-for="(item, index) in breadList"
        :key="index"
        :to="{ path: item.path }"
        >{{ item.title }}
      </el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<script>
import { ifTitle } from "@/assets/js/arrFn.js";

export default {
  data() {
    return {
      breadList: [],
    };
  },

  watch: {
    $route:{
      deep:true,
      immediate:true,
      handler(val){
        let arr = [{path:'/home',title:'首页'}];
        val.matched.forEach((item)=>{
          let {title,path}=item.meta;
          if(ifTitle(arr,title)){
            arr.push({arr,title})
          }
        })
        this.breadList=arr
      }
    }
      },
};
</script>

<style lang="less" scoped>
</style>